提供在云端上新建规则、根据ID查询规则详情、编辑规则、根据ID删除规则的、对规则的分页带条件查询、启用/禁用规则、根据ID列表批量删除规则、批量启用/禁用规则的功能
功能描述:提供新建规则的功能,入参为规则具体内容,返回新增结果。
POST /api/v1/rules
Body:
| Name | Type | Description | Required |
|---|---|---|---|
| name | string | 规则名 | Yes |
| conditions | struct[] | 触发器结构体数组 | No (conditions和timeTrigger中至少必填一个) |
| timeTrigger | string | 时间触发器 支持cron表达式(0 0 3,18 ? ) | No (trigger和timeTrigger中至少必填一个) |
| filters | struct[] | 过滤条件 | No |
| actions | struct[] | 执行设备信息结构体数组 | No (actions、subscription、ExportClientId、nextRuleId中至少必填一个) |
| subscription | string[] | 接收人邮箱列表 | No (actions、subscription、exportClientId、nextRuleId中至少必填一个) |
| exportClientId | int | 消息路由客户端ID | No (actions、subscription、exportClientId、nextRuleId中至少必填一个) |
| nextRuleId | string | 下一个要执行的规则Id | No (actions、subscription、exportClientId、nextRuleId中至少必填一个) |
| nextRuleName | string | 下一个要执行的规则名称 | No |
| mailServerId | string | 邮箱服务器的ID (5d142946688d5c0006ecb92e) | No |
| mailPatternId | string | 邮件模板的ID (5d142946688d5c0006ecb92e) | No |
| ruleType | int | 规则类型,1-云端 | Yes |
conditions的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) | No(默认是1) |
| productId | int | 触发产品ID | Yes |
| didList | int[] | 触发设备ID,空数组则代表该产品下的所有设备 | No(didList和labelId二者传其一) |
| parameter | string | 触发设备属性名(定义功能时添加的属性名) | No(type=1时必填) |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | No(type=1时必填) |
| operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | No(type=1时必填) |
| labelId | int | 分组ID,对该分组下的所有设备生效 | No(didList和labelId二者传其一) |
filter的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| type | int | 过滤类型(1:条件过滤;2:时间过滤) | Yes |
| filterDevice | struct | 条件过滤 | No(type为1时必填) |
| filterTime | struct | 时间过滤 | No(type为2时必填) |
filterDevice的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| productId | int | 触发产品ID | Yes |
| deviceId | int | 触发设备ID | Yes |
| parameter | string | 触发设备属性名(定义功能时添加的属性名) | Yes |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | Yes |
| operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | Yes |
filterTime的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| start | string | 开始时间(时:分 12:00) | Yes |
| end | string | 结束时间(时:分 12:00) | Yes |
actions的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| productId | int | 执行产品ID | Yes |
| deviceId | int | 执行设备ID | Yes |
| identifier | string | 需执行的属性名(具有写权限的属性) | Yes |
| value | 任意类型 | 值(bool值写成true或者false,int写成数字) | Yes |
Body example:
Body中含有actions和conditions的情况:
{
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "!=",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "string",
"ruleType": 1
}
Body中含有timeTrigger和actions的情况:
{
"timeTrigger": "0 0 3,18 * * ?",
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"name": "strrringw2111",
"ruleType": 1
}
Body中含有exportClientId和conditions的情况:
{
"exportClientId": 10267,
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "!=",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "strrringw2f111",
"ruleType": 1
}
Body中含有timeTrigger和subscription的情况:
{
"timeTrigger": "0 0 3,18 * * ?",
"subscription": ["1980361262@qq.com"],
"name": "strrringw2111",
"ruleType": 1
}
cURL example:
Body中含有actions和conditions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "!=",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "string11",
"ruleType": 1
}'
Body中含有timeTrigger和actions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"timeTrigger": "0 0 3,18 * * ?",
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"name": "strrringw2111",
"ruleType": 1
}'
Body中含有exportClientId和conditions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"exportClientId": 10267,
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "!=",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "strrringw2f111",
"ruleType": 1
}'
Body中含有timeTrigger和subscription的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"timeTrigger": "0 0 3,18 * * ?",
"subscription": ["1980361262@qq.com"],
"name": "strrringw2111",
"ruleType": 1
}'
Response:
| Name | Type | Description |
|---|---|---|
| data | int | 新建的规则ID |
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": "8ae491be7096bd2301709a46d7170009"
}
功能描述:提供根据id查询规则详情的功能,返回规则详情。
GET /api/v1/rules/{ruleId}
Path:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleId | string | 规则的ID | Yes |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'projectId: {projectId}' \
--header 'platform: 1'
Response data:
| Name | Type | Description |
|---|---|---|
| id | string | 规则ID |
| name | string | 规则名称 |
| userId | string | 用户ID |
| userName | string | 用户名称 |
| timeTrigger | string | 时间触发器,支持cron表达式 |
| conditions | struct[] | 触发器结构体数组 |
| actions | struct[] | 执行设备信息结构体数组 |
| subscription | string[] | 接收人邮箱列表 |
| mailServerId | string | 邮箱服务器ID |
| mailServerName | string | 邮箱服务器名称 |
| mailPatternId | string | 邮件模板ID |
| mailPatternName | string | 邮件模板名称 |
| export | boolean | 是否推送到export client |
| exportClientId | int | 消息路由客户端ID |
| ruleType | int | 规则类型,1-云端 |
| status | enum | 规则状态(0:禁用,1:启用) |
Response data conditions的子对象结构体:
| Name | Type | Description |
|---|---|---|
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
| productId | int | 触发产品ID |
| didList | int[] | 触发设备ID列表 |
| productName | string | 触发产品名称 |
| nameList | string[] | 触发设备名称列表 |
| protocolType | int | 协议类型 |
| check | struct | 触发器详情 |
| labelId | int | 分组ID |
| labelName | string | 分组名 |
Response data check的子对象结构体:
| Name | Type | Description |
|---|---|---|
| parameter | string | 触发设备属性名(定义功能时添加的属性名) |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) |
| operand | 任意类型 | 阈值(bool值写成true或者false,int写成数字) |
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
Response data actions的子对象结构体:
| Name | Type | Description |
|---|---|---|
| productId | int | 执行产品ID |
| deviceId | int | 执行设备ID |
| identifier | string | 需执行的属性名(具有写权限的属性) |
| value | 任意类型 | 值(bool值写成true或者false,int写成数字) |
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
| protocolType | int | 协议类型 |
| deviceName | string | 执行设备名称 |
| productName | string | 执行产品名称 |
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": {
"id": "8ae48daf7163309a0171ee0575150010",
"name": "string111",
"userId": "1bb9909ee93647df883b9043743a345d",
"userName": "liubo3",
"timeTrigger": null,
"conditions": [
{
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"labelId": null,
"labelName": null,
"check": {
"parameter": "abcd",
"operation": "!=",
"operand": "true",
"type": 2
},
"type": 2,
"nameList": [
"crcr"
],
"didList": [
10000781
]
}
],
"filters": [],
"actions": [
{
"deviceId": 10000781,
"deviceName": "crcr",
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"identifier": "abcd",
"value": "true",
"type": 2
}
],
"subscription": [],
"mailServerId": "",
"mailServerName": "",
"mailPatternId": "",
"mailPatternName": "",
"export": false,
"exportClientId": null,
"ruleType": 1,
"status": "DISABLED"
}
}
功能描述:更新规则的功能,入参为规则具体内容。
PUT /api/v1/rules/{ruleId}
Path:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleId | string | 规则的ID | Yes |
Body:
| Name | Type | Description | Required |
|---|---|---|---|
| name | string | 规则名 | No |
| conditions | struct[] | 触发器结构体数组 | No |
| timeTrigger | string | 时间触发器 支持cron表达式(0 0 3,18 ? ) | No |
| filters | struct[] | 过滤条件 | No |
| actions | struct[] | 执行设备信息结构体数组 | No |
| subscription | string[] | 接收人邮箱列表 | No |
| exportClientId | int | 消息路由客户端ID | No |
| mailServerId | string | 邮箱服务器的ID (5d142946688d5c0006ecb92e) | No |
| mailPatternId | string | 邮件模板的ID (5d142946688d5c0006ecb92e) | No |
conditions的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) | No(默认是1) |
| productId | int | 触发产品ID | Yes |
| didList | int[] | 触发设备ID,空数组则代表该产品下的所有设备 | No(didList和labelId二者传其一) |
| parameter | string | 触发设备属性名(定义功能时添加的属性名) | No(type=1时必填) |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | No(type=1时必填) |
| operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | No(type=1时必填) |
| labelId | int | 分组ID | No(didList和labelId二者传其一) |
filter的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| type | int | 过滤类型(1:条件过滤;2:时间过滤) | Yes |
| filterDevice | struct | 条件过滤 | No(type为1时必填) |
| filterTime | struct | 时间过滤 | No(type为2时必填) |
filterDevice的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| productId | int | 触发产品ID | Yes |
| deviceId | int | 触发设备ID | Yes |
| parameter | string | 触发设备属性名(定义功能时添加的属性名) | Yes |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | Yes |
| operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | Yes |
filterTime的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| start | string | 开始时间(时:分 12:00) | Yes |
| end | string | 结束时间(时:分 12:00) | Yes |
actions的子对象结构体:
| Name | Type | Description | Required |
|---|---|---|---|
| productId | int | 执行产品ID | Yes |
| deviceId | int | 执行设备ID | Yes |
| identifier | string | 需执行的属性名(具有写权限的属性) | Yes |
| value | 任意类型 | 值(bool值写成true或者false,int写成数字) | Yes |
Body example:
{
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "==",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "string111",
"ruleType": 1
}
cURL example:
curl --location --request PUT '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"actions": [
{
"deviceId": 10000781,
"identifier": "abcd",
"productId": 100235,
"value": "true"
}
],
"conditions": [
{
"didList": [
10000781
],
"operand": "true",
"operation": "==",
"parameter": "abcd",
"productId": 100235,
"type": 2
}
],
"name": "string111",
"ruleType": 1
}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}
功能描述:提供根据id删除规则的功能,返回删除结果。
DELETE /api/v1/rules/{ruleId}
Path:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleId | string | 规则的ID | Yes |
Query:
| Name | Description | Required | Type | marks |
|---|---|---|---|---|
| accessKeyId | 用户访问服务所用的密钥ID | Yes | string | 系统生成,在生成用户时获取 |
| signature | 签名结果串 | Yes | string | 不校验,备用字段 |
| signatureNonce | 签名随机数 | Yes | int | 1小时内,同一用户需使用不同数字 |
cURL example:
curl --location --request DELETE '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}
功能描述:提供对规则的分页带条件查询功能,返回规则列表。
GET /api/v1/rules
Query:
| Name | Type | Description | Required |
|---|---|---|---|
| accessKeyId | string | 用户访问服务所用的密钥ID,系统生成,在生成用户时获取 | Yes |
| signature | string | 签名结果串,不校验,备用字段 | Yes |
| signatureNonce | int | 签名随机数,1小时内,同一用户需使用不同数字 | Yes |
| pageSize | int | 分页大小 | Yes |
| currentPage | int | 页码 | Yes |
| name | string | 规则名 | No |
| type | int | 规则类型,1-云端 | No |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646¤tPage={currentPage}&pageSize={pageSize}' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response data:
| Name | Type | Description |
|---|---|---|
| totalCount | int | 总数量 |
| pageSize | int | 分页大小 |
| currentPage | int | 页码 |
| totalPage | int | 总页数 |
| content | struct[] | 内容 |
Response data content的子对象结构体:
| Name | Type | Description |
|---|---|---|
| id | string | 规则ID |
| name | string | 规则名称 |
| userId | string | 用户ID |
| userName | string | 用户名称 |
| timeTrigger | string | 时间触发器,支持cron表达式 |
| conditions | struct[] | 触发器结构体数组 |
| actions | struct[] | 执行设备信息结构体数组 |
| subscription | string[] | 接收人邮箱列表 |
| mailServerId | string | 邮箱服务器ID |
| mailServerName | string | 邮箱服务器名称 |
| mailPatternId | string | 邮件模板ID |
| mailPatternName | string | 邮件模板名称 |
| export | boolean | 是否推送到export client |
| exportClientId | int | 消息路由客户端ID |
| ruleType | int | 规则类型,1:云端 |
| status | enum | 规则状态(0:禁用,1:启用) |
Response data conditions的子对象结构体:
| Name | Type | Description |
|---|---|---|
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
| productId | int | 触发产品ID |
| didList | int[] | 触发设备ID列表 |
| productName | string | 触发产品名称 |
| nameList | string[] | 触发设备名称列表 |
| protocolType | int | 协议类型 |
| check | struct | 触发器详情 |
| labelId | int | 分组ID |
| labelName | int | 分组名 |
Response data check的子对象结构体:
| Name | Type | Description |
|---|---|---|
| parameter | string | 触发设备属性名(定义功能时添加的属性名) |
| operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) |
| operand | 任意类型 | 阈值(bool值写成true或者false,int写成数字) |
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
Response data actions的子对象结构体:
| Name | Type | Description |
|---|---|---|
| productId | int | 执行产品ID |
| deviceId | int | 执行设备ID |
| identifier | string | 需执行的属性名(具有写权限的属性) |
| value | 任意类型 | 值(bool值写成true或者false,int写成数字) |
| type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
| protocolType | int | 协议类型 |
| deviceName | string | 执行设备名称 |
| productName | string | 执行产品名称 |
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": {
"currentPage": 1,
"pageSize": 10,
"totalCount": 1,
"totalPage": 1,
"content": [
{
"id": "8ae48daf7163309a0171ee0575150010",
"name": "string111",
"userId": "1bb9909ee93647df883b9043743a345d",
"userName": "liubo3",
"timeTrigger": null,
"conditions": [
{
"productName": "cdedd",
"productId": 100235,
"labelId": null,
"labelName": null,
"protocolType": 5,
"check": {
"parameter": "abcd",
"operation": "!=",
"operand": "true",
"type": 2
},
"type": 2,
"nameList": [
"crcr"
],
"didList": [
10000781
]
}
],
"filters": [],
"actions": [
{
"deviceId": 10000781,
"deviceName": "crcr",
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"identifier": "abcd",
"value": "true",
"type": 2
}
],
"subscription": [],
"mailServerId": "",
"mailServerName": "",
"mailPatternId": "",
"mailPatternName": "",
"export": false,
"exportClientId": null,
"ruleType": 1
}
]
}
}
功能描述:启用物联网中的特定规则引擎,使规则引擎能够进行条件触发,执行相应的动作。
PUT /api/v1/rules/{ruleId}/enable
Path:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleId | string | 规则的ID | Yes |
cURL example:
curl --location --request PUT '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}/enable?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}
功能描述:禁用物联网中的特定规则,禁止规则进行条件触发,执行相应的动作。
PUT /api/v1/rules/{ruleId}/disable
Path:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleId | string | 规则的ID | Yes |
cURL example:
curl --location --request PUT '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}/disable?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}
功能描述:根据id列表批量删除规则。
DELETE /api/v1/rules
Body:
| Name | Type | Description | Required |
|---|---|---|---|
| idList | string[] | 规则ID数组 | Yes |
Body example:
["8ae48daf7163309a0171ee0575150010","9ae48daf7163309a0171ee0575150010"]
cURL example:
curl --location --request DELETE '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '["8ae48daf7163309a0171ee0575150010","9ae48daf7163309a0171ee0575150010"]'
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": null
}
功能描述:批量启用/禁用规则。
POST /api/v1/rules/status
Body:
| Name | Type | Description | Required |
|---|---|---|---|
| ruleName | string | 规则名称 | No |
| ruleId | string[] | 规则ID数组 | Yes |
| status | enum | 规则状态(0:禁用,1:启用) | Yes |
Body example:
{
"ruleId": [
"8ae48daf7163309a0171ee0575150010"
],
"status": 1
}
cURL example:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/status?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"ruleId": [
"8ae48daf7163309a0171ee0575150010"
],
"status": 1
}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}